package com.chlitina.store.modules.cash.model;

import java.util.ArrayList;
import java.util.List;

import com.chlitina.store.modules.base.entity.StoreCare;
import com.chlitina.store.modules.base.entity.StoreProduct;
import com.chlitina.store.modules.cash.entity.StoreConsume;
import com.chlitina.store.modules.cash.entity.StoreConsumeBuyProduct;
import com.chlitina.store.modules.cash.entity.StoreConsumeDoCare;

public class Consume {
	private StoreConsume storeConsume=null;
	private List<StoreConsumeDoCare> cares;
	private List<StoreConsumeBuyProduct> products;
	
	private List<String> productDescriptions=new ArrayList<String>();
	private List<String> careDescriptions=new ArrayList<String>();
	private String description;

	public List<StoreConsumeDoCare> getCares() {
		return cares;
	}

	public void setCares(List<StoreConsumeDoCare> cares) {
		this.cares = cares;
	}

	public List<StoreConsumeBuyProduct> getProducts() {
		return products;
	}

	public void setProducts(List<StoreConsumeBuyProduct> products) {
		this.products = products;
	}

	public StoreConsume getStoreConsume() {
		return storeConsume;
	}

	public void setStoreConsume(StoreConsume storeConsume) {
		this.storeConsume = storeConsume;
	}

	public List<String> getCareDescriptions() {
		return careDescriptions;
	}

	public List<String> getProductDescriptions() {
		return productDescriptions;
	}
 
	
	private String getName(StoreProduct storeProduct){
		if(storeProduct.getProduct_type()==StoreProduct.TYPE_SELF){
			return storeProduct.getStoreSelfProduct().getName();
		}else{
			return storeProduct.getProduct().getName();
		}
		
	}
	
	private String getName(StoreCare storeCare){
		if(storeCare.getCare_type()==StoreCare.TYPE_SELF){
			return storeCare.getStoreSelfCare().getName();
		}else{
			return storeCare.getCare().getName();
		}
		
	}
	
	
	public void updateDecriptions(){
		StringBuilder sb=new StringBuilder();
		productDescriptions.clear();
		if(products!=null&& !products.isEmpty()){
			sb.append("<strong>购买产品</strong><br/>");
			int i=1;
			for (StoreConsumeBuyProduct p : products) {
				sb.append(i+++".【"+getName(p.getStoreProduct())+"】, 数量 ："+p.getAmount()+"<br/>");
				 
			}
		}
		
		careDescriptions.clear();
		if(cares!=null&& !cares.isEmpty()){
			sb.append("<strong>手工护理</strong><br/>");
			int i=1;
			for (StoreConsumeDoCare c : cares) {
				sb.append(i+++".【"+getName(c.getStoreCare())+"】, 数量 ："+1+"<br/>");
			}
		}
		description=sb.toString();
		
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	 
}
